package com.foreveross.common.filter;


import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.stereotype.Controller;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.foreveross.common.TaskManager.CommonService;
import com.foreveross.common.TaskManager.HouseRepairTaskService;
import com.foreveross.common.TaskManager.VistorCheckService;
import com.foreveross.weixin.service.FrequencyService;
@Controller
public class TaskManagerListener implements ServletContextListener{
	private FrequencyService frequencyService;
	
	private CommonService commonService; 
	
	private VistorCheckService vistorCheckService;
	
	private HouseRepairTaskService houseRepairTaskService;
	
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		/*frequencyService.getTimer().cancel();
		commonService.getTimer().cancel();
		vistorCheckService.getTimer().cancel();
        event.getServletContext().log("定时器销毁"); */
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		event.getServletContext().log("定时器已启动");   
	 	/*frequencyService = new FrequencyService();
		//设置AccessToken
		frequencyService.setAccessToken();
		//设置JsApiTicket
		frequencyService.setJsApiTicket();
	 	
	 	WebApplicationContext applicationContext =  WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());    
        this.vistorCheckService=(VistorCheckService)applicationContext.getBean("vistorCheckService"); 
	 	vistorCheckService.updateVistorCheckStateTimer();
		
        this.commonService=(CommonService)applicationContext.getBean("commonService");   
		//定时删除文件
		commonService.deleteFilesTimer();
		
		//更新报修状态
		this.houseRepairTaskService=(HouseRepairTaskService)applicationContext.getBean("houseRepairTaskService"); 
		houseRepairTaskService.updateHouseRepairStatusTimer();
		event.getServletContext().log("已经添加任务调度表"); */
	}

}
